package com.cmc.cloud.cmclink.doc.api.document.req.so;

import com.cmc.cloud.cmclink.doc.util.so.CompareUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 订舱预配信息 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 *
 * @author codegen
 */
@Data
public class SoForecastBaseVO {

    @Schema(description = "外键", requiredMode = Schema.RequiredMode.REQUIRED, example = "30566")
    private Long soId;

    @Schema(description = "箱型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotBlank(message = "{soforecast.cntrtype.notblank}")
    @Length(max = 2, message = "{soforecast.cntrtype.length}")
    private String cntrType;

    @Schema(description = "箱尺寸", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{soforecast.cntrsize.notblank}")
    @Length(max = 2, message = "{soforecast.cntrsize.length}")
    private String cntrSize;

    @Schema(description = "箱量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "{soforecast.cntrquantity.notnull}")
    @Min(value = 1, message = "{soforecast.cntrquantity.min}")
    private Long cntrQuantity;

    @Schema(description = "单箱货重", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "{soforecast.percntrwgt.notnull}")
    @Min(value = 0, message = "{soforecast.percntrwgt.min}")
    private BigDecimal perCntrWgt;

    public static CompareUtils<SoForecastBaseVO> getMultiFieldComparator() {
        return new CompareUtils<SoForecastBaseVO>().comparingField(SoForecastBaseVO::getCntrType)
                .thenComparing(SoForecastBaseVO::getCntrSize)
                .thenComparing(SoForecastBaseVO::getCntrQuantity);
    }

}
